package com.tbit.uqbike.center.aop;

import com.tbit.uqbike.center.constant.SystemConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.cloud.context.refresh.ContextRefresher;
import org.springframework.cloud.endpoint.event.RefreshEvent;
import org.springframework.cloud.endpoint.event.RefreshEventListener;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 17:40 2022/11/18
 */
@Configuration
public class ConfigRefreshEventListener extends RefreshEventListener {

    @Autowired
    private SystemConstant systemConstant;

    public ConfigRefreshEventListener(
            ContextRefresher refresh) {
        super(refresh);
    }

    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
        return super.supportsEventType(eventType);
    }

    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        super.onApplicationEvent(event);
    }

    @Override
    public void handle(ApplicationReadyEvent event) {
        super.handle(event);
    }

    @Override
    public void handle(RefreshEvent event) {
        super.handle(event);
        systemConstant.refresh();
    }

}
